package com.yanqu.road.server.cmd.strongholdwar;

import com.yanqu.road.entity.rank.cross.CrossUserRank;
import com.yanqu.road.logic.pb.CrossRankPb;
import com.yanqu.road.pb.cross.activity.CrossActivityProto;
import com.yanqu.road.pb.rank.RankProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.strongholdwar.CrossStrongholdRankMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_CROSS_ACTIVITY_USER_RANK_CHANGE_NEW, desc = "跨服活动个人排行数据变更")
public class CrossActivityUserRankChangeCmd extends CrossUnionCommand {
    private int activityId;
    private int conditionType;
    private boolean isAll;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        CrossActivityProto.CrossActivityUserRankChangeReqMsg req = CrossActivityProto.CrossActivityUserRankChangeReqMsg.parseFrom(packet.getBytes());
        isAll = req.getIsAll();
        conditionType = req.getConditionType();
        activityId = req.getActivityId();
        for (RankProto.RankTempMsg temMsg : req.getDataListList()) {
            CrossUserRank crossUserRank = CrossRankPb.parseCrossUserRank(activityId, temMsg, conditionType);
            CrossStrongholdRankMgr.changeStrongholdUserRank(activityId, crossUserRank);
        }
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData() {

    }
}
